from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support import wait
import time

browser = webdriver.Firefox()
browser.get('http://192.168.1.209:8085//')
#点击红包
red = browser.find_element_by_id('red-box')
red.click()
browser.find_element_by_link_text('取消').click()
#跳转到 立即登录页面
#browser.find_element_by_link_text('立即登录').click()
#弹出窗口的 确定 取消  警告窗口也是这样
#confirm = browser.switch_to.alert
# confirm.accept()
# confirm.dismiss()

#滚动到底部
browser.execute_script("document.documentElement.scrollTop=10000")

#隐藏红包 不然点击不了下边的关闭
browser.execute_script("document.getElementById('red-box').hidden = true")
#关闭广告
ad = browser.find_element_by_class_name('close-box')
if ad.is_enabled():
    ad.click()

wode = browser.find_element_by_link_text('我的')
wode.click()

browser.execute_script("document.documentElement.scrollTop=10000")

login = browser.find_element_by_id('login_a')
login.click()
queding = browser.find_element_by_class_name('weui_btn_dialog ')
tishi = browser.find_element_by_class_name('weui_dialog_bd ')
assert tishi.text == '请输入用户名或者手机号'
assert queding.text == '确定'
queding.click()

username = browser.find_element_by_id('username')
username.send_keys('18300001109')
password = browser.find_element_by_id('password')
password.send_keys('abcd1234')
browser.execute_script("document.documentElement.scrollTop=10000")
time.sleep(2)
login.click()
browser.implicitly_wait(5)

touzi = browser.find_element_by_partial_link_text('理财')
touzi.click()

biaodi = browser.find_element_by_css_selector("a[href='/borrowInfo/detail.htm?borrowId=6501061226433004']")
biaodi.click()
money = browser.find_element_by_id('money')
money.send_keys(4000)

browser.execute_script("document.documentElement.scrollTop=10000")

kaquan = browser.find_element_by_id('showvoucher')
kaquan.click()
kaquan_quxiao =browser.find_element_by_class_name('close-coupond ')
kaquan_quxiao.click()

# money.clear()
# money.send_keys(1)
# yuqishouyi =browser.find_element_by_id('incomeMoney')
# assert yuqishouyi.text == '0.01元'
#
# money.clear()
# money.send_keys(500)
# assert yuqishouyi.text == '7.50元'
#
# money.clear()
# money.send_keys(600)
# assert yuqishouyi.text == '8.50元'

lijitouzi =browser.find_element_by_class_name('btn-tz')
lijitouzi.click()

xinlang_zhifu =browser.find_element_by_id('J-payPwd_Savings')
xinlang_zhifu.send_keys('abcd@1234')

xinlang_zhifu_wancheng =browser.find_element_by_class_name('btn-danger')
xinlang_zhifu_wancheng.click()




